package com.blr.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: WebMvcConfig
 * Description: 自定义 mvc 配置类
 * Date: 2022/11/08 PM 3:10:08
 * <p>
 * project: codes
 * package: config
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
//@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 用来全局处理跨域
     *
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")// 对那些请求进行跨域处理
                .allowCredentials(false)
                .allowedHeaders("*")
                .allowedMethods("*")
                .allowedOrigins("*")
                .maxAge(3600);
    }
}
